<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:gp="http://gp.componentes.jsf" >

<ui:composition template="/WEB-INF/adicional/templates/templateHome.xhtml">

	<ui:define name="tituloPagina">
		Alterar Clinicas
	</ui:define>
	
	<ui:define name="conteudoCabecalho">
		
		<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/clinica/alterarClinicaFormulario.js">
		</script>
		
		<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/js/clinica/clinica.js">
		</script>
	
		<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/resources/componentes/autoComplete/js/autoComplete.js">
		</script>

		<link rel="stylesheet" href="#{facesContext.externalContext.requestContextPath}/tabs.css" />	
		
	</ui:define>
	
	<ui:define name="conteudoCentro">
		
		<h:form id="formularioImagem" enctype="multipart/form-data" target="frameAlterarClinica">
			
			<p:dialog widgetVar="dialogImagem" id="dialogImagem" resizable="false" closable="true" header="Upload Imagem"
			visible="false" modal="true">
			
				<div id="containerMsgImagem" class="campo_invisivel">
				
				</div>
				
					
				<div>
					<img id="imagemClinicaEscolhida" class="imagem_clinica" src="#{facesContext.externalContext.requestContextPath}/imagem"/>
				</div>
		
				
				<div>
					<h:outputText value="Escolha uma imagem para a Clinica: " />
				</div>
				
				<div>
					<h:inputFile id="imagemClinica" label="Imagem da Clinica"
						value="#{clinica.imagemClinicaAlt}"></h:inputFile>
				</div>
				
				<div>
					<p:commandButton value="Enviar Imagem" action="#{clinica.uploadImagemAlt()}" ajax="false"></p:commandButton>
				</div>
			
			</p:dialog>
		
		</h:form>


		<h:form id="formularioAlterar">
		
			<h:panelGrid rendered="#{clinica.flagFrameAlt}">
			
				<script type="text/javascript">
				
					$("#containerMsgImagem", top.document).removeClass('campo_invisivel');
	
					$("#containerMsgImagem", top.document).html("#{clinica.msgImagemAlt}");
	
					
				</script>
				
			</h:panelGrid>
			
			<div>
				<p:messages showSummary="true" showDetail="true" closable="true"></p:messages>
			</div>
			
			<div class="ui-messages-error ui-corner-all campo_invisivel" id="containerErro">
					
					
			</div>
			
			<div>
				<h:outputLabel value="Nome: "  for="nomeClinica"/>
				<h:inputText value="#{clinica.nomeClinicaAlt}"  id="nomeClinica" maxlength="100" 
				label="Nome da Clinica" binding="#{clinica.campoNomeClinicaAlt}"/>
			</div>
			
			<div>
				<h:outputLabel value="Cnpj: " for="cnpjClinica" />
				<h:inputText value="#{clinica.cnpjClinicaAlt}" id="cnpjClinica" maxlength="14" 
				label="Cnpj da Clinica" binding="#{clinica.campoCnpjClinicaAlt}"/>
			</div>
			
			<br />	
				
			<gp:tabs idTabs="detalheClinica" tabsClass="classeTabs" headerClass="classeHeader"
			hideEffect="blind" hideDuration="1000" showEffect="blind" showDuration="1000" collapsible="true" >
			
				<gp:tab titulo="Email" idSubTab="tabEmail" delete="true" subTabClass="classeSubTab" bodyClass="classeBody" >

					<div>
						<p:messages showSummary="true" showDetail="true" closable="true"></p:messages>
					</div>

					<h:panelGrid id="containerEmail">

						<div>
							<h:outputLabel value="Email: " for="emailClinica" />
							<h:inputText value="#{clinica.emailClinicaAux}"
								binding="#{clinica.campoEmailClinciaInc}" id="emailClinica"
								label="Email" maxlength="100" />

							<p:commandButton action="#{clinica.salvarEmailAux()}"
								value="Incluir" update=":formularioAlterar:containerEmail" />
						</div>

						<div>
							<p:dataTable value="#{clinica.listaDialogEmail}" var="email"
								paginator="true" rows="10" emptyMessage="Não há Registros"
								id="tabelaEmail">
								<p:column headerText="e-Mails" id="tabelaEmail">
									<h:outputText value="#{email.emailClinica}" />
								</p:column>
								<p:column headerText="">
									<p:commandButton action="#{clinica.excluirEmailAux(email)}"
										value="Excluir" update=":formularioAlterar:containerEmail"></p:commandButton>
								</p:column>

							</p:dataTable>
						</div>
					</h:panelGrid>

				</gp:tab>
				
				<gp:tab titulo="Telefone" idSubTab="tabTelefone" delete="true" subTabClass="classeSubTab" bodyClass="classeBody" >

					<div>
						<p:messages showSummary="true" showDetail="true" closable="true"></p:messages>
					</div>

					<h:panelGrid id="containerTelefone">

						<div>
							<h:outputLabel value="DDD: " for="dddClinica" />
							<h:inputText value="#{clinica.dddClinicaAux}" id="dddClinica"
								label="DDD" maxlength="2" />

							<h:outputLabel value="Telefone: " for="telefoneClinica" />
							<h:inputText value="#{clinica.telefoneClinicaAux}"
								id="telefoneClinica" label="Telefone" maxlength="9" />

							<h:outputLabel value="Tipo Telefone: " for="tipoTelefone" />
							<h:selectOneMenu value="#{clinica.codTipoTelefoneAux}"
								id="tipoTelefone" label="Tipo Telefone">

								<f:selectItem itemLabel="::SELECIONE::" itemValue="0" />
								<f:selectItems value="#{clinica.listaTipoTelefoneAux}"></f:selectItems>

							</h:selectOneMenu>

							<p:commandButton action="#{clinica.salvarTelefoneAux()}"
								value="Incluir" update=":formularioAlterar:containerTelefone"></p:commandButton>
						</div>

						<div>

							<p:dataTable value="#{clinica.listaDialogTelefone}"
								var="telefone" paginator="true" rows="10"
								emptyMessage="Não há Registros" id="telefoneTable">

								<p:column headerText="DDD">
									<h:outputFormat value="#{telefone.dddClinica}" />
								</p:column>
								<p:column headerText="Telefones">
									<h:outputText value="#{telefone.telefoneClinica}" />
								</p:column>
								<p:column headerText="Tipo de Telefones">
									<h:outputText value="#{telefone.tipoTelefone.descricao}" />
								</p:column>

								<p:column>
									<p:commandButton
										action="#{clinica.excluirTelefoneAux(telefone)}"
										value="Excluir" update=":formularioAlterar:containerTelefone"></p:commandButton>
								</p:column>

							</p:dataTable>
						</div>

					</h:panelGrid>

				</gp:tab>
				
				<gp:tab titulo="Endereço" idSubTab="tabEndereco" delete="true" subTabClass="classeSubTab" bodyClass="classeBody" >

					<div>
						<p:messages showSummary="true" showDetail="true" closable="true"></p:messages>
					</div>

					<h:panelGrid id="containerEndereco">
						<div>
							<h:outputLabel value="Estado: " for="comboEstado" />
							<h:selectOneMenu value="#{clinica.codEstadoAux}" id="comboEstado"
								label="Estados">

								<f:ajax event="change"
									listener="#{clinica.buscarCidadePorEstadoAux}"
									render="comboCidade"></f:ajax>

								<f:selectItem itemValue="0" itemLabel="::SELECIONE::" />
								<f:selectItems value="#{clinica.listaEstadosAux}" />

							</h:selectOneMenu>

							<h:outputLabel value="Cidade: " for="comboCidade" />
							<h:selectOneMenu value="#{clinica.codCidadeAux}"
								binding="#{clinica.campoCidadeAux}" id="comboCidade"
								label="Cidades" disabled="#{empty clinica.listaCidadesAux}">

								<f:selectItem itemValue="0" itemLabel="::SELECIONE::" />
								<f:selectItems value="#{clinica.listaCidadesAux}" />

							</h:selectOneMenu>

							<h:outputLabel value="Logradouro: " for="logradouroClinica" />
							<h:inputText value="#{clinica.logradouroClinicaAux}"
								id="logradouroClinica" label="Logradouro Clinica"
								maxlength="200" />
						</div>

						<div>
							<h:outputLabel value="Bairro: " for="bairroClinica" />
							<h:inputText value="#{clinica.bairroClinicaAux}"
								id="bairroClinica" label="Bairro Clinica" maxlength="150" />

							<h:outputLabel value="#{msgs.incluir_clinica_label_cep}"
								for="cepClinica" />
							<h:inputText value="#{clinica.cepClinicaAux}" id="cepClinica"
								label="Cep Clinica" maxlength="8" />

							<h:outputLabel value="Complemento: " for="complementoClinica" />
							<h:inputText value="#{clinica.complementoClinicaAux}"
								id="complementoClinica" label="Complemento Clinica"
								maxlength="100" />

							<p:commandButton action="#{clinica.salvarEnderecoAux()}"
								value="Incluir" update=":formularioAlterar:containerEndereco"></p:commandButton>
						</div>

						<div>
							<p:dataTable value="#{clinica.listaDialogEndereco}"
								var="endereco" paginator="true" rows="10"
								emptyMessage="Não há Registro" id="enderecoTable">
								<p:column headerText="Rua">
									<h:outputText value="#{endereco.logradouroClinica}" />
								</p:column>
								<p:column headerText="Bairro">
									<h:outputText value="#{endereco.bairroClinica}" />
								</p:column>
								<p:column headerText="CEP">
									<h:outputText value="#{endereco.cepClinica}" />
								</p:column>
								<p:column headerText="Cidade">
									<h:outputText value="#{endereco.cidade.nomeCidade}" />
								</p:column>
								<p:column headerText="Estado">
									<h:outputText value="#{endereco.cidade.estado.nomeEstado}" />
								</p:column>

								<p:column>
									<p:commandButton
										action="#{clinica.excluirEnderecoAux(endereco)}"
										value="Excluir" update=":formularioAlterar:containerEndereco"></p:commandButton>
								</p:column>
							</p:dataTable>
						</div>
					</h:panelGrid>
				</gp:tab>
				
				<gp:tab titulo="Imagem" idSubTab="tabImagem" subTabClass="classeSubTab" bodyClass="classeBody" >
				
					<h:commandLink value="Abrir Dialog de Imagem"  onclick="PF('dialogImagem').show();return false"/>
				
				</gp:tab>
					
			</gp:tabs>
			
			<br />
			
			<div>
				<p:commandButton action="#{clinica.alterarClinica}" value="Enviar" onclick="return validarFormularioAlt();" 
				update="@form"></p:commandButton>
				
				<p:commandButton action="#{clinica.limparFormularioAlterar()}" value="Limpar" onclick="return limparFormularioAlt();" update="@form"
				immediate="true"></p:commandButton>
			</div>

			<iframe name="frameAlterarClinica" class="campo_invisivel">
		
			</iframe>
			
		</h:form>
	
	</ui:define>
	
</ui:composition>
</html>